﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuanLyBanHang.VO
{
    public class PhieuNhap_VO
    {
        public string NCC;
        public int MaNV;
        public int MaPN;
        List<CartItem> _items;
        public PhieuNhap_VO(string ncc)
        {
            NCC = ncc;
            _items = new List<CartItem>();
        }
        public PhieuNhap_VO()
        {
            _items = new List<CartItem>();
        }
        public List<CartItem> Items
        {
            get { return _items; }
            set { _items = value; }
        }
        public bool AddCart(CartItem c)
        {
            foreach (CartItem e in Items)
            {
                if (e.MaSP == c.MaSP)
                {
                    e.soluong += c.soluong;
                    return true;
                }
            }
            _items.Add(c);
            return true;
        }
        public void Clean()
        {
            foreach (CartItem e in Items)
            {
                if (e.soluong <= 0) Items.Remove(e);
            }
        }
        long _tonggia;
        public long TongGia
        {
            get
            {
                long tong=0;
                foreach(CartItem c in _items)
                {
                    tong += c.TongGia;
                }
                return tong;
            }
            set
            {
                _tonggia = value;
            }
        }
        
    }
}
